
#pragma once
//#include "uniform.h"
#include <math.h>
#include <iostream>
using namespace std;


class uniform
{
private:
 double generate_num;
 int * seed = (int*)311;
 int M, N;

public:
 uniform()
 {
  M = 1048576;
  N = 2045;
 }
 void generate();
 double random_number(double, double);
};

double uniform::random_number(double a, double b)
{
 (*seed) = N * (*seed) + 1;
 (*seed) = (*seed) - ((*seed) / M) * M;
 generate_num = static_cast<double>((*seed)) / M;
 generate_num = a + (b - a) * generate_num;
 return generate_num;
}


class laplace
{
private:
 double beta=0.5, u1=1, u2=1, generate_num=0;
public:
 laplace() {}
 void generate();
 double random_number(double);
};

double laplace::random_number(double beta)
{
 uniform unif_num;
 u1 = unif_num.random_number(0.0, 1.0);
 u2 = unif_num.random_number(0.0, 1.0);
 if (u1 <= 0.5)
  generate_num = -beta * log(1 - u2);
 else
  generate_num= beta * log(u2);
 cout<<generate_num<<endl;
 return generate_num;
}

